package com.learn.ch02ttlqueue.consumer;

import com.learn.ch02ttlqueue.config.RabbitMqConfig;
import com.rabbitmq.client.Channel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * @author DJJ_F
 * @version 1.0
 * @date 2025/08/24
 * @description ch07
 * 延迟队列 qd的消费者
 */
@Component
@Slf4j
public class TtlConsumer {
    @RabbitListener(queues = "QD")
    public void receiveD(Message message, Channel channel) {
        log.info("time: {}, message: {}", new Date(), new String(message.getBody()));
    }

    @RabbitListener(queues = RabbitMqConfig.DELAYED_QUEUE)
    public void receiveDelayed(Message message, Channel channel) {
        log.info("time: {}, message: {}", new Date(), new String(message.getBody()));
    }
}
